package com.jiangyao.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiangyao.common.ApiResult;
import com.jiangyao.model.dto.PublicSubjectDto;
import com.jiangyao.model.entity.Category;
import com.jiangyao.model.vo.PublicSubjectListVo;
import com.jiangyao.service.SubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/public")
@Api(tags = "公开课相关接口")
public class PublicController extends BaseController{
    @Autowired
    private SubjectService subjectService;

    @PostMapping("getPublicCategory")
    @ApiOperation(value = "获取公开课分类")
    public ApiResult<Category> getPublicCategory (){
        return ApiResult.success(subjectService.getPublicCategory());
    }

    @PostMapping("getPublicChoiceness")
    @ApiOperation(value = "获取精选课程列表")
    public ApiResult<Page<PublicSubjectListVo>> getPublicChoiceness (@RequestBody PublicSubjectDto dto){
        return ApiResult.success(subjectService.getPublicChoiceness(dto));
    }

    @PostMapping("getPublicNewest")
    @ApiOperation(value = "获取新上好课列表")
    public ApiResult<Page<PublicSubjectListVo>> getPublicNewest (@RequestBody PublicSubjectDto dto){
        return ApiResult.success(subjectService.getPublicNewest(dto));
    }
}
